package com.rhtchr.angelbaby.knowledge;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.rhtchr.angelbaby.customer.CustomerDao;
import com.rhtchr.angelbaby.domain.Topic;
import com.rhtchr.angelbaby.domain.VArticle;

public class TopicManager {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new TopicManager().insertTopicData();
	}

	public void insertTopicData() {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
		ArticleDao articleDao = (ArticleDao) applicationContext.getBean("articleDao");
		List<VArticle> tmp = articleDao.find("From VArticle va Where va.topicId = ? ", 1);
		System.out.println(tmp.size());
		CustomerDao customerDao = (CustomerDao) applicationContext.getBean("customerDao");
		HibernateTemplate hibernateTemplate = customerDao.getHibernateTemplate();
		List find = hibernateTemplate.find("From Topic t");
		for (Object object : find) {
			System.out.println(((Topic) object).toString());
		}
		try {

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
